﻿using System;
using System.Collections.Generic;
using System.Text;
using DotNet.Common.Command;
using ZLCMS.Business.WeixinService;

namespace ZLCMS.Web.ZLOAuth.Code
{
    /// <summary>
    /// GetAccessToken命令参数
    /// </summary>
    public class GetAccessTokenParameter : CommandParameter
    {
    }

    /// <summary>
    /// GetAccessToken命令调用输出
    /// </summary>
    public class GetAccessTokenResult
    {
        public string AccessToken { get; set; }
    }

    /// <summary>
    /// GetAccessToken命令
    /// </summary>
    public class GetAccessTokenCommand : SessionCommand<GetAccessTokenResult>
    {
        public override ICommandResult<GetAccessTokenResult> Execute(NHibernate.ISession session, ICommandParameter parameter)
        {
            ICommandResult<GetAccessTokenResult> result = new CommandResult<GetAccessTokenResult>();
            GetAccessTokenParameter param = parameter as GetAccessTokenParameter;
            if (param != null)
            {
                //在这里添加命令内容
                result.Result.AccessToken = WeixinUtil.GetAccessToken("admin");
            }
            else
            {
                result.ErrorCode = "0001";
            }
            return result;
        }

    }
}
